/*
 * Copyright Nucleron R&D LLC 2016
 *
 * This file is licensed under the terms of YAPL,
 * see License.txt for details.
 */

// #include <libopencm3/stm32/rcc.h>
// #include <libopencm3/stm32/timer.h>

// #include <libopencm3/cm3/cortex.h>
// #include <libopencm3/cm3/nvic.h>
// #include <libopencm3/cm3/scb.h>

#include <plc_config.h>
#include <plc_iom.h>
#include <plc_rtc.h>
#include <plc_wait_tmr.h>
#include <Arduino.h>
HardwareTimer timer(TIM7);

volatile uint32_t plc_sys_timer = 0;

void PLC_WAIT_TMR_IRQ(HardwareTimer *arg)
{

    plc_sys_timer++;
    plc_iom_tick();
}

void plc_wait_tmr_init(void)
{
    timer.setOverflow(1000, HERTZ_FORMAT);
    timer.attachInterrupt(PLC_WAIT_TMR_IRQ);
    timer.resume();
}
